180. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-03-13 03:01:04 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

180.1 Files compared

#LocationFileLast Modified
1Porto v4.0.4/Porto Theme/app/code/Smartwave/Porto/view/frontend/web/jsimagesloaded.js2016-02-10 12:44:18 +0000
2Porto v4.0.5/Porto Theme/app/code/Smartwave/Porto/view/frontend/web/jsimagesloaded.js2022-12-02 03:29:26 +0000

180.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged74648
Changed62250
Inserted59
Removed720

180.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

180.4 Active regular expressions

No regular expressions were active.

180.5 Comparison detail

1 /*! 1 /*!
2  * imagesLoaded PACKAGED v4.1.0 2  * imagesLoaded PACKAGED v5.0.0
3  * JavaScript is all like "You images are done yet or what?" 3  * JavaScript is all like "You images are done yet or what?"
4  * MIT License 4  * MIT License
5  */ 5  */
6  6 
7 /** 7 /**
8  * EvEmitter v1.0.1 8  * EvEmitter v2.1.1
9  * Lil' event emitter 9  * Lil' event emitter
10  * MIT License 10  * MIT License
11  */ 11  */
12  12 
13 /* jshint unused: true, undef: true, strict: true */    
14     
15 ( function( global, factory ) { 13 ( function( global, factory ) {
16   // universal module definition 14   // universal module definition
17   /* jshint strict: false */ /* globals define, module */ 15   
if ( typeof module == 'object' && module.exports ) {
18   if ( typeof define == 'function' && define.amd ) {    
19     // AMD - RequireJS    
20     define( 'ev-emitter/ev-emitter',factory );    
21   } else if ( typeof module == 'object' && module.exports ) {    
22     // CommonJS - Browserify, Webpack 16     // CommonJS - Browserify, Webpack
23     module.exports = factory(); 17     module.exports = factory();
24   } else { 18   } else {
25     // Browser globals 19     // Browser globals
26     global.EvEmitter = factory(); 20     global.EvEmitter = factory();
27   } 21   }
28  22 
29 }( 
this, function() {
 23 }( typeof window != 'undefined' ? window : this, function() {
30     
31     
32  24 
33 function EvEmitter() {} 25 function EvEmitter() {}
34  26 
35 var proto = EvEmitter.prototype; 27 let proto = EvEmitter.prototype;
36  28 
37 proto.on = function( eventName, listener ) { 29 proto.on = function( eventName, listener ) {
38   if ( !eventName || !listener ) { 30   if ( !eventName || !listener ) return this;
39     return; 31 
40   }    
41   // set events hash 32   // set events hash
42   var events = this._events = this._events || {}; 33   let events = this._events = this._events || {};
43   // set listeners array 34   // set listeners array
44   var listeners = events[ eventName ] = events[ eventName ] || []; 35   let listeners = events[ eventName ] = events[ eventName ] || [];
45   // only add once 36   // only add once
46   if ( 
listeners.indexOf( listener ) == -1 ) {
 37   if ( !listeners.includes( listener ) 
) {
47     listeners.push( listener ); 38     listeners.push( listener );
48   } 39   }
49  40 
50   return this; 41   return this;
51 }; 42 };
52  43 
53 proto.once = function( eventName, listener ) { 44 proto.once = function( eventName, listener ) {
54   if ( !eventName || !listener ) { 45   if ( !eventName || !listener ) return this;
55     return; 46 
56   }    
57   // add event 47   // add event
58   this.on( eventName, listener ); 48   this.on( eventName, listener );
59   // set once flag 49   // set once flag
60   // set onceEvents hash 50   // set onceEvents hash
61   var onceEvents = this._onceEvents = this._onceEvents || {}; 51   let onceEvents = this._onceEvents = this._onceEvents || {};
62   // set onceListeners array 52   // set onceListeners object
63   var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || []; 53   let onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
64   // set flag 54   // set flag
65   onceListeners[ listener ] = true; 55   onceListeners[ listener ] = true;
66  56 
67   return this; 57   return this;
68 }; 58 };
69  59 
70 proto.off = function( eventName, listener ) { 60 proto.off = function( eventName, listener ) {
71   var listeners = this._events && this._events[ eventName ]; 61   let listeners = this._events && this._events[ eventName ];
72   if ( !listeners || !listeners.length ) { 62   if ( !listeners || !listeners.length ) return this;
73     return; 63 
74   } 64   let index = listeners.indexOf( listener );
75   var index = listeners.indexOf( listener );    
76   if ( index != -1 ) { 65   if ( index != -1 ) {
77     listeners.splice( index, 1 ); 66     listeners.splice( index, 1 );
78   } 67   }
79  68 
80   return this; 69   return this;
81 }; 70 };
82  71 
83 proto.emitEvent = function( eventName, args ) { 72 proto.emitEvent = function( eventName, args ) {
84   var listeners = this._events && this._events[ eventName ]; 73   let listeners = this._events && this._events[ eventName ];
85   if ( !listeners || !listeners.length ) { 74   if ( !listeners || !listeners.length ) return this;
86     return; 75 
87   } 76   // copy over to avoid interference if .off() in listener
88   var i = 0; 77   listeners = listeners.slice( 0 );
89   var listener = listeners[i];    
90   args = args || []; 78   args = args || [];
91   // once stuff 79   // once stuff
92   var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; 80   let onceListeners = this._onceEvents && this._onceEvents[ eventName ];
93  81 
94   while ( 
listener 
) {
 82   for ( let listener of listeners ) {
95     var isOnce = onceListeners && onceListeners[ listener ]; 83     let isOnce = onceListeners && onceListeners[ listener ];
96     if ( isOnce ) { 84     if ( isOnce ) {
97       // remove listener 85       // remove listener
98       // remove before trigger to prevent recursion 86       // remove before trigger to prevent recursion
99       this.off( eventName, listener ); 87       this.off( eventName, listener );
100       // unset once flag 88       // unset once flag
101       delete onceListeners[ listener ]; 89       delete onceListeners[ listener ];
102     } 90     }
103     // trigger listener 91     // trigger listener
104     listener.apply( this, args ); 92     listener.apply( this, args );
105     // get next listener    
106     i += isOnce ? 0 : 1;    
107     listener = listeners[i];    
108   } 93   }
109  94 
110   return this; 95   return this;
111 }; 96 };
112  97 
113 
return EvEmitter;
 98 proto.allOff = function() {
    99   delete this._events;
    100   delete this._onceEvents;
    101   return this;
    102 };
114  103 
115 })); 104 return EvEmitter;
116  105 
    106 } ) );
117 /*! 107 /*!
118  * imagesLoaded v4.1.0 108  * imagesLoaded v5.0.0
119  * JavaScript is all like "You images are done yet or what?" 109  * JavaScript is all like "You images are done yet or what?"
120  * MIT License 110  * MIT License
121  */ 111  */
122  112 
123 ( function( window, factory ) { 'use strict'; 113 ( function( window, factory ) {
124   // universal module definition 114   // universal module definition
125  115   
if ( typeof module == 'object' && module.exports ) {
126   /*global define: false, module: false, require: false */    
127     
128   if ( typeof define == 'function' && define.amd ) {    
129     // AMD    
130     define( [    
131       'ev-emitter/ev-emitter'    
132     ], function( EvEmitter ) {    
133       return factory( window, EvEmitter );    
134     });    
135   } else if ( typeof module == 'object' && module.exports ) {    
136     // CommonJS 116     // CommonJS
137     module.exports = factory(
 117     module.exports = factory( window, require('ev-emitter') );
138       window,    
139       require('ev-emitter')    
140     );    
141   } else { 118   } else {
142     // browser global 119     // browser global
143     window.imagesLoaded = factory(
 120     window.imagesLoaded = factory( window, window.EvEmitter );
144       window,    
145       window.EvEmitter    
146     );    
147   } 121   }
148  122 
149 })( window, 123 } )( typeof window !== 'undefined' ? window : this,
    124     function factory( window, EvEmitter ) {
150  125 
151 // --------------------------  factory -------------------------- // 126 let $ = window.jQuery;
152  127 let console = window.console;
153 function factory( window, EvEmitter ) {    
154     
155     
156     
157 var $ = window.jQuery;    
158 var console = window.console;    
159  128 
160 // -------------------------- helpers -------------------------- // 129 // -------------------------- helpers -------------------------- //
161  130 
162 // extend objects    
163 function extend( a, b ) {    
164   for ( var prop in b ) {    
165     a[ prop ] = b[ prop ];    
166   }    
167   return a;    
168 }    
169     
170 // turn element or nodeList into an array 131 // turn element or nodeList into an array
171 function makeArray( obj ) { 132 function makeArray( obj ) {
172   var ary = [];    
173   if ( Array.isArray( obj ) ) {    
174     // use object if already an array 133   // use object if already an array
175     ary = obj; 134   if ( Array.isArray( obj ) ) return obj;
176   } else if ( typeof obj.length == 'number' ) { 135 
    136   let isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
177     // convert nodeList to array 137   // convert nodeList to array
178     for ( var i=0; i < obj.length; i++ ) { 138   if ( isArrayLike ) return [ ...obj ];
179       ary.push( obj[i] ); 139 
180     }    
181   } else {    
182     // array of single index 140   // array of single index
183     ary.push( obj ); 141   return [ obj ];
184   }    
185   return ary;    
186 } 142 }
187  143 
188 // -------------------------- imagesLoaded -------------------------- // 144 // -------------------------- imagesLoaded -------------------------- //
189  145 
190 /** 146 /**
191  * @param {
Array, Element, NodeList, String
} elem
 147  * @param {[Array, Element, NodeList, String]} elem
192  * @param {
Object or Function
} options - if function, use as callback
 148  * @param {[Object, Function]} options - if function, use as callback
193  * @param {Function} onAlways - callback function 149  * @param {Function} onAlways - callback function
    150  * @returns {ImagesLoaded}
194  */ 151  */
195 function ImagesLoaded( elem, options, onAlways ) { 152 function ImagesLoaded( elem, options, onAlways ) {
196   // coerce ImagesLoaded() without new, to be new ImagesLoaded() 153   // coerce ImagesLoaded() without new, to be new ImagesLoaded()
197   if ( !( this instanceof ImagesLoaded ) ) { 154   if ( !( this instanceof ImagesLoaded ) ) {
198     return new ImagesLoaded( elem, options, onAlways ); 155     return new ImagesLoaded( elem, options, onAlways );
199   } 156   }
200   // use elem as selector string 157   // use elem as selector string
    158   let queryElem = elem;
201   if ( typeof elem == 'string' ) { 159   if ( typeof elem == 'string' ) {
202     elem = document.querySelectorAll( elem ); 160     queryElem = document.querySelectorAll( elem );
    161   }
    162   // bail if bad element
    163   if ( !queryElem ) {
    164     console.error(`Bad element for imagesLoaded ${queryElem || elem}`);
    165     return;
203   } 166   }
204  167 
205   this.elements = makeArray( elem ); 168   this.elements = makeArray( queryElem );
206   this.options = extend( {}, this.options ); 169   this.options = 
{}
;
207  170   // shift arguments if no options set
208   if ( typeof options == 'function' ) { 171   if ( typeof options == 'function' ) {
209     onAlways = options; 172     onAlways = options;
210   } else { 173   } else {
211     extend( this.options, options ); 174     Object.assign( this.options, options );
212   } 175   }
213  176 
214   if ( onAlways ) { 177   if ( onAlways ) this.on( 'always', onAlways );
215     
this.on( 'always', onAlways );
    
216   }    
217  178 
218   this.getImages(); 179   this.getImages();
219     
220   if ( $ ) {    
221     // add jQuery Deferred object 180   // add jQuery Deferred object
222     
this.jqDeferred = new $.Deferred();
 181   if ( $ ) this.jqDeferred = new $.Deferred();
223   }    
224  182 
225   // HACK check async to allow time to bind listeners 183   // HACK check async to allow time to bind listeners
226   setTimeout( function() { 184   setTimeout( this.check.bind( this ) );
227     this.check();    
228   }.bind( this )
);
    
229 } 185 }
230  186 
231 ImagesLoaded.prototype = Object.create( EvEmitter.prototype ); 187 ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
232  188 
233 ImagesLoaded.prototype.options = {};    
234     
235 ImagesLoaded.prototype.getImages = function() { 189 ImagesLoaded.prototype.getImages = function() {
236   this.images = []; 190   this.images = [];
237  191 
238   // filter & find items if we have an item selector 192   // filter & find items if we have an item selector
239   this.elements.forEach( this.addElementImages, this ); 193   this.elements.forEach( this.addElementImages, this );
240 }; 194 };
241  195 
    196 const elementNodeTypes = [ 1, 9, 11 ];
    197 
242 /** 198 /**
243  * @param {Node} element 199  * @param {Node} elem
244  */ 200  */
245 ImagesLoaded.prototype.addElementImages = function( elem ) { 201 ImagesLoaded.prototype.addElementImages = function( elem ) {
246   // filter siblings 202   // filter siblings
247   if ( elem.nodeName ==
 'IMG' ) {
 203   if ( elem.nodeName === 'IMG' ) {
248     this.addImage( elem ); 204     this.addImage( elem );
249   } 205   }
250   // get background image on element 206   // get background image on element
251   if ( this.options.background === true ) { 207   if ( this.options.background === true ) {
252     this.addElementBackgroundImages( elem ); 208     this.addElementBackgroundImages( elem );
253   } 209   }
254  210 
255   // find children 211   // find children
256   // no non-element nodes, #143 212   // no non-element nodes, #143
257   var nodeType 
= elem.nodeType;
 213   let { nodeType = elem
;
258   if ( !nodeType || !elementNodeTypes[ nodeType ] ) { 214   if ( !nodeType || !elementNodeTypes.includes( nodeType ) ) return;
259     return; 215 
260   } 216   let childImgs = elem.querySelectorAll('img');
261   var childImgs = elem.querySelectorAll('img');    
262   // concat childElems to filterFound array 217   // concat childElems to filterFound array
263   for ( var i=0; i < childImgs.length; i++ ) { 218   for ( let img of childImgs
 ) {
264     var img = childImgs[i];    
265     this.addImage( img ); 219     this.addImage( img );
266   } 220   }
267  221 
268   // get child background images 222   // get child background images
269   if ( typeof this.options.background == 'string' ) { 223   if ( typeof this.options.background == 'string' ) {
270     var children = elem.querySelectorAll( this.options.background ); 224     let children = elem.querySelectorAll( this.options.background );
271     for ( i=0; i < children.length; i++ ) { 225     for ( let child of children
 ) {
272       var child = children[i];    
273       this.addElementBackgroundImages( child ); 226       this.addElementBackgroundImages( child );
274     } 227     }
275   } 228   }
276 }; 229 };
277  230 
278 var elementNodeTypes = { 231 const reURL = /url\((['"])?(.*?)\1\)/gi;
279   1: true,    
280   9: true,    
281   11: true    
282 };    
283  232 
284 ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) { 233 ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
285   var style = getComputedStyle( elem ); 234   let style = getComputedStyle( elem );
286   if ( !style ) {    
287     // Firefox returns null if in a hidden iframe https://bugzil.la/548397 235   // Firefox returns null if in a hidden iframe https://bugzil.la/548397
288     
return;
 236   if ( !style ) return;
289   } 237 
290   // get url inside url("...") 238   // get url inside url("...")
291   var reURL = /url\((['"])?(.*?)\1\)/gi; 239   let matches = reURL.exec( style.backgroundImage );
292   var matches = reURL.exec( style.backgroundImage );    
293   while ( matches !== null ) { 240   while ( matches !== null ) {
294     var url = matches && matches[2]; 241     let url = matches && matches[2];
295     if ( url ) { 242     if ( url ) {
296       this.addBackground( url, elem ); 243       this.addBackground( url, elem );
297     } 244     }
298     matches = reURL.exec( style.backgroundImage ); 245     matches = reURL.exec( style.backgroundImage );
299   } 246   }
300 }; 247 };
301  248 
302 /** 249 /**
303  * @param {Image} img 250  * @param {Image} img
304  */ 251  */
305 ImagesLoaded.prototype.addImage = function( img ) { 252 ImagesLoaded.prototype.addImage = function( img ) {
306   var loadingImage = new LoadingImage( img ); 253   let loadingImage = new LoadingImage( img );
307   this.images.push( loadingImage ); 254   this.images.push( loadingImage );
308 }; 255 };
309  256 
310 ImagesLoaded.prototype.addBackground = function( url, elem ) { 257 ImagesLoaded.prototype.addBackground = function( url, elem ) {
311   var background = new Background( url, elem ); 258   let background = new Background( url, elem );
312   this.images.push( background ); 259   this.images.push( background );
313 }; 260 };
314  261 
315 ImagesLoaded.prototype.check = function() { 262 ImagesLoaded.prototype.check = function() {
316   var _this = this;    
317   this.progressedCount = 0; 263   this.progressedCount = 0;
318   this.hasAnyBroken = false; 264   this.hasAnyBroken = false;
319   // complete if no images 265   // complete if no images
320   if ( !this.images.length ) { 266   if ( !this.images.length ) {
321     this.complete(); 267     this.complete();
322     return; 268     return;
323   } 269   }
324  270 
325   function onProgress
( image, elem, message ) 
{
 271   /* eslint-disable-next-line func-style */
    272   let onProgress = ( image, elem, message ) => {
326     // HACK - Chrome triggers event before object properties have changed. #83 273     // HACK - Chrome triggers event before object properties have changed. #83
327     setTimeoutfunction() 
{
 274     setTimeout
() => {
328       _this.progress( image, elem, message ); 275       this.progress( image, elem, message );
329     }
);
 276     } );
330   }
 277   };
331  278 
332   this.images.forEach( function( loadingImage ) { 279   this.images.forEach( function( loadingImage ) {
333     loadingImage.once( 'progress', onProgress ); 280     loadingImage.once( 'progress', onProgress );
334     loadingImage.check(); 281     loadingImage.check();
335   }
);
 282   } );
336 }; 283 };
337  284 
338 ImagesLoaded.prototype.progress = function( image, elem, message ) { 285 ImagesLoaded.prototype.progress = function( image, elem, message ) {
339   this.progressedCount++; 286   this.progressedCount++;
340   this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded; 287   this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
341   // progress event 288   // progress event
342   this.emitEvent( 'progress', [ this, image, elem ] ); 289   this.emitEvent( 'progress', [ this, image, elem ] );
343   if ( this.jqDeferred && this.jqDeferred.notify ) { 290   if ( this.jqDeferred && this.jqDeferred.notify ) {
344     this.jqDeferred.notify( this, image ); 291     this.jqDeferred.notify( this, image );
345   } 292   }
346   // check if completed 293   // check if completed
347   if ( this.progressedCount ==
 this.images.length ) {
 294   if ( this.progressedCount === this.images.length ) {
348     this.complete(); 295     this.complete();
349   } 296   }
350  297 
351   if ( this.options.debug && console ) { 298   if ( this.options.debug && console ) {
352     console.log( 'progress: ' + message
, image, elem );
 299     console.log( `progress: ${message}`, image, elem );
353   } 300   }
354 }; 301 };
355  302 
356 ImagesLoaded.prototype.complete = function() { 303 ImagesLoaded.prototype.complete = function() {
357   var eventName = this.hasAnyBroken ? 'fail' : 'done'; 304   let eventName = this.hasAnyBroken ? 'fail' : 'done';
358   this.isComplete = true; 305   this.isComplete = true;
359   this.emitEvent( eventName, [ this ] ); 306   this.emitEvent( eventName, [ this ] );
360   this.emitEvent( 'always', [ this ] ); 307   this.emitEvent( 'always', [ this ] );
361   if ( this.jqDeferred ) { 308   if ( this.jqDeferred ) {
362     var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve'; 309     let jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
363     this.jqDeferred[ jqMethod ]( this ); 310     this.jqDeferred[ jqMethod ]( this );
364   } 311   }
365 }; 312 };
366  313 
367 // --------------------------  -------------------------- // 314 // --------------------------  -------------------------- //
368  315 
369 function LoadingImage( img ) { 316 function LoadingImage( img ) {
370   this.img = img; 317   this.img = img;
371 } 318 }
372  319 
373 LoadingImage.prototype = Object.create( EvEmitter.prototype ); 320 LoadingImage.prototype = Object.create( EvEmitter.prototype );
374  321 
375 LoadingImage.prototype.check = function() { 322 LoadingImage.prototype.check = function() {
376   // If complete is true and browser supports natural sizes, 323   // If complete is true and browser supports natural sizes,
377   // try to check for image status manually. 324   // try to check for image status manually.
378   var isComplete = this.getIsImageComplete(); 325   let isComplete = this.getIsImageComplete();
379   if ( isComplete ) { 326   if ( isComplete ) {
380     // report based on naturalWidth 327     // report based on naturalWidth
381     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); 328     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
382     return; 329     return;
383   } 330   }
384  331 
385   // If none of the checks above matched, simulate loading on detached element. 332   // If none of the checks above matched, simulate loading on detached element.
386   this.proxyImage = new Image(); 333   this.proxyImage = new Image();
    334   // add crossOrigin attribute. #204
    335   if ( this.img.crossOrigin ) {
    336     this.proxyImage.crossOrigin = this.img.crossOrigin;
    337   }
387   this.proxyImage.addEventListener( 'load', this ); 338   this.proxyImage.addEventListener( 'load', this );
388   this.proxyImage.addEventListener( 'error', this ); 339   this.proxyImage.addEventListener( 'error', this );
389   // bind to image as well for Firefox. #191 340   // bind to image as well for Firefox. #191
390   this.img.addEventListener( 'load', this ); 341   this.img.addEventListener( 'load', this );
391   this.img.addEventListener( 'error', this ); 342   this.img.addEventListener( 'error', this );
392   this.proxyImage.src = this.img.
src;
 343   this.proxyImage.src = this.img.currentSrc || this.img.src;
393 }; 344 };
394  345 
395 LoadingImage.prototype.getIsImageComplete = function() { 346 LoadingImage.prototype.getIsImageComplete = function() {
396   return this.img.complete && this.img.naturalWidth !== undefined; 347   // check for non-zero, non-undefined naturalWidth
    348   // fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
    349   return this.img.complete && this.img.naturalWidth
;
397 }; 350 };
398  351 
399 LoadingImage.prototype.confirm = function( isLoaded, message ) { 352 LoadingImage.prototype.confirm = function( isLoaded, message ) {
400   this.isLoaded = isLoaded; 353   this.isLoaded = isLoaded;
401   this.emitEvent( 'progress', [ this, this.img, message ] ); 354   let { parentNode } = this.img;
    355   // emit progress with parent <picture> or self <img>
    356   let elem = parentNode.nodeName === 'PICTURE' ? parentNode : this.img;
    357   this.emitEvent( 'progress', [ this, elem, message ] );
402 }; 358 };
403  359 
404 // ----- events ----- // 360 // ----- events ----- //
405  361 
406 // trigger specified handler for event type 362 // trigger specified handler for event type
407 LoadingImage.prototype.handleEvent = function( event ) { 363 LoadingImage.prototype.handleEvent = function( event ) {
408   var method = 'on' + event.type; 364   let method = 'on' + event.type;
409   if ( this[ method ] ) { 365   if ( this[ method ] ) {
410     this[ method ]( event ); 366     this[ method ]( event );
411   } 367   }
412 }; 368 };
413  369 
414 LoadingImage.prototype.onload = function() { 370 LoadingImage.prototype.onload = function() {
415   this.confirm( true, 'onload' ); 371   this.confirm( true, 'onload' );
416   this.unbindEvents(); 372   this.unbindEvents();
417 }; 373 };
418  374 
419 LoadingImage.prototype.onerror = function() { 375 LoadingImage.prototype.onerror = function() {
420   this.confirm( false, 'onerror' ); 376   this.confirm( false, 'onerror' );
421   this.unbindEvents(); 377   this.unbindEvents();
422 }; 378 };
423  379 
424 LoadingImage.prototype.unbindEvents = function() { 380 LoadingImage.prototype.unbindEvents = function() {
425   this.proxyImage.removeEventListener( 'load', this ); 381   this.proxyImage.removeEventListener( 'load', this );
426   this.proxyImage.removeEventListener( 'error', this ); 382   this.proxyImage.removeEventListener( 'error', this );
427   this.img.removeEventListener( 'load', this ); 383   this.img.removeEventListener( 'load', this );
428   this.img.removeEventListener( 'error', this ); 384   this.img.removeEventListener( 'error', this );
429 }; 385 };
430  386 
431 // -------------------------- Background -------------------------- // 387 // -------------------------- Background -------------------------- //
432  388 
433 function Background( url, element ) { 389 function Background( url, element ) {
434   this.url = url; 390   this.url = url;
435   this.element = element; 391   this.element = element;
436   this.img = new Image(); 392   this.img = new Image();
437 } 393 }
438  394 
439 // inherit LoadingImage prototype 395 // inherit LoadingImage prototype
440 Background.prototype = Object.create( LoadingImage.prototype ); 396 Background.prototype = Object.create( LoadingImage.prototype );
441  397 
442 Background.prototype.check = function() { 398 Background.prototype.check = function() {
443   this.img.addEventListener( 'load', this ); 399   this.img.addEventListener( 'load', this );
444   this.img.addEventListener( 'error', this ); 400   this.img.addEventListener( 'error', this );
445   this.img.src = this.url; 401   this.img.src = this.url;
446   // check if image is already complete 402   // check if image is already complete
447   var isComplete = this.getIsImageComplete(); 403   let isComplete = this.getIsImageComplete();
448   if ( isComplete ) { 404   if ( isComplete ) {
449     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); 405     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
450     this.unbindEvents(); 406     this.unbindEvents();
451   } 407   }
452 }; 408 };
453  409 
454 Background.prototype.unbindEvents = function() { 410 Background.prototype.unbindEvents = function() {
455   this.img.removeEventListener( 'load', this ); 411   this.img.removeEventListener( 'load', this );
456   this.img.removeEventListener( 'error', this ); 412   this.img.removeEventListener( 'error', this );
457 }; 413 };
458  414 
459 Background.prototype.confirm = function( isLoaded, message ) { 415 Background.prototype.confirm = function( isLoaded, message ) {
460   this.isLoaded = isLoaded; 416   this.isLoaded = isLoaded;
461   this.emitEvent( 'progress', [ this, this.element, message ] ); 417   this.emitEvent( 'progress', [ this, this.element, message ] );
462 }; 418 };
463  419 
464 // -------------------------- jQuery -------------------------- // 420 // -------------------------- jQuery -------------------------- //
465  421 
466 ImagesLoaded.makeJQueryPlugin = function( jQuery ) { 422 ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
467   jQuery = jQuery || window.jQuery; 423   jQuery = jQuery || window.jQuery;
468   if ( !jQuery ) { 424   if ( !jQuery ) return;
469     return; 425 
470   }    
471   // set local variable 426   // set local variable
472   $ = jQuery; 427   $ = jQuery;
473   // $().imagesLoaded() 428   // $().imagesLoaded()
474   $.fn.imagesLoaded = function( options, callback ) { 429   $.fn.imagesLoaded = function( options, onAlways ) {
475     var instance = new ImagesLoaded( this, options, callback ); 430     let instance = new ImagesLoaded( this, options, onAlways );
476     return instance.jqDeferred.promise( $(
this
) );
 431     return instance.jqDeferred.promise( $( this ) );
477   }; 432   };
478 }; 433 };
479 // try making plugin 434 // try making plugin
480 ImagesLoaded.makeJQueryPlugin(); 435 ImagesLoaded.makeJQueryPlugin();
481  436 
482 // --------------------------  -------------------------- // 437 // --------------------------  -------------------------- //
483  438 
484 return ImagesLoaded; 439 return ImagesLoaded;
485  440 
486 }
);
 441 } );